package fr.afcepf.ai85.gepeto.managedBean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import fr.afcepf.ai85.businessObj.ResultatFacture;
import fr.afcepf.ai85.businessObj.ResultatTarification;
import fr.afcepf.ai85.gepeto.service.ServiceFacturationGeneration;

@ManagedBean(name = "beanFactCalcul")
@SessionScoped
public class BeanFacturationGeneration {
	 // //////////////////////////  Listes ///////////////////////////////////////////////////////////////////////////
	List<ResultatTarification> listeFactCalcul = new ArrayList<ResultatTarification>();
	List<ResultatFacture> listeFacturesGenerees = new ArrayList<ResultatFacture>();

	// /////////////////////////////////////////////attribus////////////////////////////////////////////////////////////
	private String idPeriode;
	private String idEcole;

	// //////////////////////////////visibilite des panel ////////////////////////////////////////////////////////////

	String visibiliteCalcul;
	String visibilitefacturesGenerees;

	public String getVisibiliteCalcul() {
		return visibiliteCalcul;
	}

	public void setVisibiliteCalcul(String visibiliteCalcul) {
		this.visibiliteCalcul = visibiliteCalcul;
	}

	public String getVisibilitefacturesGenerees() {
		return visibilitefacturesGenerees;
	}

	public void setVisibilitefacturesGenerees(String visibilitefacturesGenerees) {
		this.visibilitefacturesGenerees = visibilitefacturesGenerees;
	}

	public List<ResultatFacture> getListeFacturesGenerees() {
		return listeFacturesGenerees;
	}

	public void setListeFacturesGenerees(
			List<ResultatFacture> listeFacturesGenerees) {
		this.listeFacturesGenerees = listeFacturesGenerees;
	}

	public List<ResultatTarification> getListeFactCalcul() {
		return listeFactCalcul;
	}

	public void setListeFactCalcul(List<ResultatTarification> listeFactCalcul) {
		this.listeFactCalcul = listeFactCalcul;
	}

	public String getIdPeriode() {
		return idPeriode;
	}

	public void setIdPeriode(String idPeriode) {
		this.idPeriode = idPeriode;
	}

	public String getIdEcole() {
		return idEcole;
	}

	public void setIdEcole(String idEcole) {
		this.idEcole = idEcole;
	}

	public String chargementTableCalculFactures() {
	
		listeFactCalcul.clear();
		visibiliteCalcul = "true";
		int iIdPeriode = Integer.parseInt(idPeriode);
		System.out.println("iIdPeriode = " + idPeriode);

		int iIdEcole = Integer.parseInt(idEcole);
		System.out.println("iIdEcole = " + idEcole);

		listeFactCalcul = ServiceFacturationGeneration.CalculDesFactures(
				iIdPeriode, iIdEcole);
		System.out.println("Bean facturation : chargementTableFacture()");
		System.out.println(listeFactCalcul);

		return "";
	}


	public  String chargementTableFacturesGenerees() {
		listeFactCalcul.clear();
		listeFacturesGenerees.clear();
		System.out.println("je rentre dans ma methode");
//		visibiliteCalcul = "false";
//		visibilitefacturesGenerees = "true";
		int iIdPeriode = Integer.parseInt(idPeriode);
		System.out.println("iIdPeriode = " + idPeriode);

		int iIdEcole = Integer.parseInt(idEcole);
		System.out.println("iIdEcole = " + idEcole);
		listeFacturesGenerees = ServiceFacturationGeneration.GenerationFactures(iIdPeriode, iIdEcole);
		
		for (ResultatFacture r : listeFacturesGenerees ){
			
			System.out.println(r.idFacture);
		}
		
		return "";

	}


}
